package zookeeper_tool;

import org.apache.zookeeper.WatchedEvent;
import org.apache.zookeeper.Watcher;
import org.apache.zookeeper.ZooKeeper;

public class Start
{

    public static void main(String[] args) throws Exception
    {

        int CONNECTION_TIMEOUT = 10;
        ZooKeeper zooKeeper = new ZooKeeper("192.168.1.102:2181",
                CONNECTION_TIMEOUT, new Watcher()
        {
            // 监控所有被触发的事件
            public void process(WatchedEvent watchedEvent)
            {
                System.out.println(watchedEvent);
            }
        });

        String path = "/drds";
        zooKeeper.addAuthInfo("digest", "drds:123456".getBytes());

        for (String string :
                zooKeeper.getChildren("/", null))
        {
            System.out.println(string);
        }
    }
}
